package com.squid.auth.controller;

import com.alibaba.excel.annotation.ExcelProperty;
import com.squid.auth.model.entity.TokenEntity;
import com.squid.auth.model.req.LoginReq;
import com.squid.auth.model.req.TokenReq;
import com.squid.auth.model.resp.LoginResp;
import com.squid.auth.service.login.LoginService;
import com.squid.base.common.bean.Return;
import com.squid.base.utils.ExcelUtils;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.search.RequiredSearch;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.Data;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * 登录controller
 *
 * @author jinhang1
 * @date 2024/07/18
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @Resource
    LoginService loginService;
    @Resource
    SimpleMeterRegistry simpleMeterRegistry;

    /**
     * 登录
     *
     * @param req
     * @return {@link Return }<{@link String }>
     */
    @PostMapping("login")
    public Return<LoginResp> login(@RequestBody LoginReq req) {
        LoginResp login = loginService.login(req);
        return Return.<LoginResp>success().data(login);
    }

    /**
     * 注销
     *
     * @param req
     * @return {@link Return }<{@link Object }>
     */
    @PostMapping("logout")
    public Return<Object> logout(@RequestBody LoginReq req) {
        return Return.success();
    }

    /**
     * 刷新令牌
     *
     * @param req
     * @return {@link Return }<{@link Object }>
     */
    @PostMapping("refreshToken")
    public Return<String> refreshToken(@RequestBody TokenReq req) {
        String resp = loginService.refreshToken(req.getToken());
        return Return.<String>success().data(resp);
    }
    @PostMapping("import")
    public Return<Object> importData( @RequestParam(value = "file")  MultipartFile file){
        return Return.success();
    }
    @PostMapping("export")
    public void exportFile(HttpServletResponse response){

    }

}
